<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>流程列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.4/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <table class="layui-hide" id="workFlow" lay-filter="workFlow"></table>
    </div>
    <script type="text/html" id="viewBar">
        <a class="layui-btn layui-btn-xs" lay-event="view">查看流程图</a>
    </script>
</div>
</body>
<script src="/lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    layui.use(['table'], function () {
        var table = layui.table,
            $ = layui.jquery;
        // 表格
        table.render({
            elem: '#workFlow',
            url: '/api/admin/workflow/list',
            page: true,
            cols: [
                [
                    {field: 'id', title: '流程ID', align: 'center', sort: true},
                    {field: 'name', title: '流程名称', align: 'center'},
                    {field: 'version', title: '版本', align: 'center'},
                    {field: 'key', title: '流程key', align: 'center'},
                    {field: 'description', title: '描述', align: 'center'},
                    {fixed: 'right', title: '操作', toolbar: '#viewBar', align: 'center'}
                ]
            ]
        });
        //监听工具条
        table.on('tool(workFlow)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if (layEvent === 'view') {
                layer.open({
                    id: 'model-view',
                    type: 2,
                    area: ['600px', '300px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: "流程图",
                    content: '/api/admin/workflow/list/view?processDefinitionId=' + data.id
                });
            }
        });
    });
    /*]]>*/
</script>
</html>